package com.cg.controller;

import com.cg.config.Result;
import com.cg.service.PurchaseService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
@Slf4j
public class PurchaseController {

    private final PurchaseService purchaseService;

    @GetMapping("/purchase/{userId}/{stockId}")
    public Result purchase(@PathVariable("userId") Integer userId, @PathVariable("stockId") Long stockId){
        log.info("用户id:{}",userId);
        return purchaseService.doPurchase(userId,stockId);
    }

}
